<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <script type="text/javascript" src="../lib/js/jquery3.6.0.js"></script>
    <script type="text/javascript" src="../lib/js/bootstrap.js"></script>
    <link rel="stylesheet" href="../lib/css/bootstrap.css">
    <script type="text/javascript">
        $(function () {
            const $username = $("#username");
            const $password = $("#password");
            const $sub = $("#sub");
            const t1 = $("#text1");
            const t2 = $("#text2");
            const other = /^\w{2,14}$/;
            const label1 = $("#l1");
            var x = 0;
            var $input = $("input");
            $sub.click(function () {

                $.ajax({
                    url: "http://localhost:8080/bookStore2/user/servlet.do",
                    type: "GET",
                    data: {
                        action:"login",
                        username: $username.val(),
                        password: $password.val(),
                    },
                    success: function (data) {
                        //响应成功后的回调函数
                        console.log(data);
                        alert(data)
                    },
                    //响应的数据类型格式
                    dataType: "text"
                })
            })
            /*$input.blur(function () {
                if (!other.test($username.val().trim()) || !other.test($password.val().trim()))
                    $sub.prop("disabled", true)
                label1.text("输入信息有误，禁止注册")
            })*/
            /*$input.click(function () {
                $sub.prop("disabled", false)

            })*/
            $username.blur(function () {
                if (!other.test($username.val().trim())) {
                    t1.text("用户名必须为6-14位");
                }
            })
            /*$username.focus(function () {
                t1.html(" &nbsp;");

            })*/

            $password.blur(function () {
                if (!other.test($password.val().trim())) {
                    t2.text("密码必须为6-14位");
                }
            })
            /*$password.focus(function () {
                t2.html(" &nbsp;");

            })*/
        })
    </script>
</head>
<body style="background-color:#f0d264;">
<nav class="navbar navbar-default navbar-fixed-top" style="color: #f6ffa4; background:#191a16">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="../index.html">主页</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1" style="margin-left: 100px">
            <form class="navbar-form navbar-left" style="margin-left: 250px">
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="搜索你想要的内容">
                </div>
                <button type="submit" class="btn btn-danger">搜索</button>
            </form>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="./user_login.html">登录</a></li>
                <li><a href="./register.html">注册</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
                       aria-haspopup="true" aria-expanded="false">账户设置<span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="#">编辑资料</a></li>
                        <li><a href="#">账户设置</a></li>
                        <li><a href="#">更多</a></li>
                        <li role="separator" class="divider"></li>
                        <li><a href="#">退出</a></li>
                    </ul>
                </li>
            </ul>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fl uid -->
</nav>
<div style="align-self: center; background-color:#26A65B;  position: absolute ;top: 0px; width: 600px; right: 50px; height: 100%">

    <div style="width: 400px;margin-top: 300px; margin-left: 100px">
        <h1 style="font-family:'楷体',serif;font-size: 60px;color: #f0d264; margin-left: 20px">登录</h1>
        <form>
            <div class="input1 input-group">
                <span class="input-group-addon">用户名</span>
                <input type="text" class="form-control" name="username" placeholder="Username"
                       id="username" aria-describedby="basic-addon1">
            </div>
            <span class="text1" id="text1">&nbsp;</span>
            <br>
            <br>
            <div class="input1 input-group">
                <span class="input-group-addon">密码</span>
                <input type="password" class="form-control" name="password" placeholder="password"
                       id="password" aria-describedby="basic-addon1">
            </div>
            <span class="text1" id="text2">&nbsp;</span>
            <br>
            <br>
            <button id="sub" style="text-align: center; margin-left: 160px;width: 60px;height: 30px" class="btn-danger" disabled="disabled">
                登录
            </button>
<!--
            <label id="l1"></label>
-->
        </form>
    </div>
</div>

</body>
</html>